//
// DyneTK, the Dyne Toolkit
// Copyright (C) 2007 Matthias Melcher
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//

// generated by Fast Light User Interface Designer (fluid) version 1.0108

#include "Fldtk_Justify_Slot_Editor.h"
#include <FL/Fl_Input.H>

Fl_Menu_Item Fldtk_Justify_Slot_Editor::menu_wHParent[] = {
 {"Left Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Center Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Right Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Full Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

Fl_Menu_Item Fldtk_Justify_Slot_Editor::menu_wHSibling[] = {
 {"None", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Left Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Center Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Right Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Full Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

Fl_Menu_Item Fldtk_Justify_Slot_Editor::menu_wVParent[] = {
 {"Top Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Center Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Bottom Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Full Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

Fl_Menu_Item Fldtk_Justify_Slot_Editor::menu_wVSibling[] = {
 {"None", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Top Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Center Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Bottom Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Full Relative", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

Fl_Menu_Item Fldtk_Justify_Slot_Editor::menu_wHText[] = {
 {"Left", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Right", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Center", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Full", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

Fl_Menu_Item Fldtk_Justify_Slot_Editor::menu_wVText[] = {
 {"Top", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Center", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Bottom", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"Full", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

Fl_Menu_Item Fldtk_Justify_Slot_Editor::menu_wTextLimits[] = {
 {"No limit", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"One line only", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"One word only", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {"One character only", 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 0},
 {0,0,0,0,0,0,0,0,0}
};

Fldtk_Justify_Slot_Editor::Fldtk_Justify_Slot_Editor(Fl_Group *container, Dtk_Value_Slot *slot) : Fldtk_Value_Slot_Editor(container, slot), value_(0) {
  wValue_->hide();
position(0, 0);
begin();
buildUI_();
end();
position(container->x(), container->y());
}

Fldtk_Justify_Slot_Editor::~Fldtk_Justify_Slot_Editor() {
}

void Fldtk_Justify_Slot_Editor::value(double v) {
  value_ = (unsigned int)v;
wHText->value( value_&3 ); // bits 0 1
wVText->value( (value_>>2)&3 ); // bits 2 3
wHParent->value( (value_>>4)&3 ); // bits 4 5
wVParent->value( (value_>>6)&3 ); // bits 6 7
wAnchored->value( (value_ & 0x00000100) ? 1 : 0 ); // bit 8
wLasso->value( (value_ & 0x00008000) ? 1 : 0 ); // bit 15
wReflow->value( (value_ & 0x00010000) ? 1 : 0 ); // bit 16
wTextLimits->value( (value_>>19)&3 ); // bits 19 20
wPropLeft->value( (value_ & 0x04000000) ? 1 : 0); // bit 26
wPropRight->value( (value_ & 0x08000000) ? 1 : 0); // bit 27
wPropTop->value( (value_ & 0x10000000) ? 1 : 0); // bit 28
wPropBottom->value( (value_ & 0xe0000000) ? 1 : 0); // bits 29 30 31 (why?)
switch (value_ & 0x00000e00) { // bits 9 10 11
  case 0x0800: wHSibling->value(1); break; // left
  case 0x0200: wHSibling->value(2); break; // center
  case 0x0400: wHSibling->value(3); break; // right
  case 0x0600: wHSibling->value(4); break; // full
  default: wHSibling->value(0); break;
}
switch (value_ & 0x00007000) { // bits 12 13 14
  case 0x4000: wVSibling->value(1); break; // top 
  case 0x1000: wVSibling->value(2); break; // center
  case 0x2000: wVSibling->value(3); break; // bottom
  case 0x3000: wVSibling->value(4); break; // full
  default: wVSibling->value(0); break;
}
}

double Fldtk_Justify_Slot_Editor::value() {
  unsigned int v = value_;

v &= 0xffffff0f;

v |= ( wHParent->value() << 4 );
v |= ( wVParent->value() << 6 );

return (double)v;
}

Fl_Group* Fldtk_Justify_Slot_Editor::buildUI_() {
  Fl_Group* w;
  { Fl_Group* o = new Fl_Group(0, 0, 430, 290);
    w = o;
    o->box(FL_FLAT_BOX);
    o->color(FL_BACKGROUND_COLOR);
    o->selection_color(FL_BACKGROUND_COLOR);
    o->labeltype(FL_NO_LABEL);
    o->labelfont(0);
    o->labelsize(14);
    o->labelcolor(FL_FOREGROUND_COLOR);
    o->user_data((void*)(this));
    o->align(FL_ALIGN_TOP);
    o->when(FL_WHEN_RELEASE);
    { Fl_Group* o = new Fl_Group(5, 10, 410, 75, "View Position:");
      o->box(FL_THIN_DOWN_BOX);
      o->labelsize(12);
      o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
      { Fl_Box* o = new Fl_Box(15, 30, 65, 20, "Horizontal:");
        o->labelsize(12);
        o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
      } // Fl_Box* o
      { wHParent = new Fl_Choice(125, 30, 115, 20, "Parent:");
        wHParent->down_box(FL_BORDER_BOX);
        wHParent->labelsize(12);
        wHParent->textsize(12);
        wHParent->menu(menu_wHParent);
      } // Fl_Choice* wHParent
      { wHSibling = new Fl_Choice(290, 30, 115, 20, "Sibling:");
        wHSibling->down_box(FL_BORDER_BOX);
        wHSibling->labelsize(12);
        wHSibling->textsize(12);
        wHSibling->deactivate();
        wHSibling->menu(menu_wHSibling);
      } // Fl_Choice* wHSibling
      { Fl_Box* o = new Fl_Box(15, 55, 65, 20, "Vertical:");
        o->labelsize(12);
        o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
      } // Fl_Box* o
      { wVParent = new Fl_Choice(125, 55, 115, 20, "Parent:");
        wVParent->down_box(FL_BORDER_BOX);
        wVParent->labelsize(12);
        wVParent->textsize(12);
        wVParent->menu(menu_wVParent);
      } // Fl_Choice* wVParent
      { wVSibling = new Fl_Choice(290, 55, 115, 20, "Sibling:");
        wVSibling->down_box(FL_BORDER_BOX);
        wVSibling->labelsize(12);
        wVSibling->textsize(12);
        wVSibling->deactivate();
        wVSibling->menu(menu_wVSibling);
      } // Fl_Choice* wVSibling
      o->end();
    } // Fl_Group* o
    { Fl_Group* o = new Fl_Group(5, 95, 410, 60, "Proportional Bounds:");
      o->box(FL_THIN_DOWN_BOX);
      o->labelsize(12);
      o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
      o->deactivate();
      { wPropLeft = new Fl_Check_Button(20, 120, 70, 20, "Left");
        wPropLeft->down_box(FL_DOWN_BOX);
        wPropLeft->labelsize(12);
        wPropLeft->deactivate();
      } // Fl_Check_Button* wPropLeft
      { wPropRight = new Fl_Check_Button(90, 120, 70, 20, "Right");
        wPropRight->down_box(FL_DOWN_BOX);
        wPropRight->labelsize(12);
        wPropRight->deactivate();
      } // Fl_Check_Button* wPropRight
      { wPropTop = new Fl_Check_Button(160, 120, 70, 20, "Top");
        wPropTop->down_box(FL_DOWN_BOX);
        wPropTop->labelsize(12);
        wPropTop->deactivate();
      } // Fl_Check_Button* wPropTop
      { wPropBottom = new Fl_Check_Button(230, 120, 70, 20, "Bottom");
        wPropBottom->down_box(FL_DOWN_BOX);
        wPropBottom->labelsize(12);
        wPropBottom->deactivate();
      } // Fl_Check_Button* wPropBottom
      o->end();
    } // Fl_Group* o
    { Fl_Group* o = new Fl_Group(5, 165, 240, 110, "Text/Graphics:");
      o->box(FL_THIN_DOWN_BOX);
      o->labelsize(12);
      o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
      o->deactivate();
      { wHText = new Fl_Choice(85, 190, 150, 20, "Horizontal:");
        wHText->down_box(FL_BORDER_BOX);
        wHText->labelsize(12);
        wHText->textsize(12);
        wHText->deactivate();
        wHText->menu(menu_wHText);
      } // Fl_Choice* wHText
      { wVText = new Fl_Choice(85, 215, 150, 20, "Vertical:");
        wVText->down_box(FL_BORDER_BOX);
        wVText->labelsize(12);
        wVText->textsize(12);
        wVText->deactivate();
        wVText->menu(menu_wVText);
      } // Fl_Choice* wVText
      { wTextLimits = new Fl_Choice(85, 240, 150, 20, "Text Limits:");
        wTextLimits->down_box(FL_BORDER_BOX);
        wTextLimits->labelsize(12);
        wTextLimits->textsize(12);
        wTextLimits->deactivate();
        wTextLimits->menu(menu_wTextLimits);
      } // Fl_Choice* wTextLimits
      o->end();
    } // Fl_Group* o
    { Fl_Group* o = new Fl_Group(255, 165, 160, 70, "Printing:");
      o->box(FL_THIN_DOWN_BOX);
      o->labelsize(12);
      o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
      o->deactivate();
      { wReflow = new Fl_Check_Button(265, 185, 115, 20, "Reflow");
        wReflow->down_box(FL_DOWN_BOX);
        wReflow->labelsize(12);
        wReflow->deactivate();
      } // Fl_Check_Button* wReflow
      { wLasso = new Fl_Check_Button(265, 205, 115, 20, "Lasso Children");
        wLasso->down_box(FL_DOWN_BOX);
        wLasso->labelsize(12);
        wLasso->deactivate();
      } // Fl_Check_Button* wLasso
      o->end();
    } // Fl_Group* o
    { wAnchored = new Fl_Check_Button(265, 245, 115, 20, "Anchored");
      wAnchored->down_box(FL_DOWN_BOX);
      wAnchored->labelsize(12);
      wAnchored->deactivate();
    } // Fl_Check_Button* wAnchored
    { Fl_Box* o = new Fl_Box(415, 275, 10, 10);
      Fl_Group::current()->resizable(o);
    } // Fl_Box* o
    o->end();
  } // Fl_Group* o
  return w;
}

//
// DyneTK, the Dyne Toolkit
// Copyright (C) 2007 Matthias Melcher
//
